package com.bruan.d5_objectoutputstream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class Test1ObjectOutputStream {
    public static void main(String[] args) {
        //1.创建对象
        User u = new User("张三","zhang",11,"dwadwawd");
        try(
                ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("file-io-app\\zlive.txt"));
                ) {
            os.writeObject(u);
            System.out.println("序列化对象成功!");

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
